public class wrok2 {
    //191. 位1的个数
    public int hammingWeight1(int n) {
        int sum=0;
        while(n!=0){
            sum+=n&1;
            n>>=1;//n=n>>1;
        }
        return sum;
    }
    public int hammingWeight2(int n) {
        int sum=0;
        while(n!=0){
            n=n&n-1;
            sum++;
        }
        return sum;
    }
}
